package com.android.fragmentdemo
import android.os.Bundle
import androidx.recyclerview.widget.ItemTouchHelper
import com.android.fragmentdemo.adapters.CardItemAdapter
import com.hengfoxwolf.commonbase.base.BaseActivity
import com.android.fragmentdemo.databeans.DataFactoryIp
import com.android.fragmentdemo.databinding.ActivityCardItemBinding
import com.android.fragmentdemo.definervlayoutmanager.CardItemTouchCallback
import com.android.fragmentdemo.definervlayoutmanager.CardLayoutManager

class CardItemActivity : BaseActivity<ActivityCardItemBinding>() {

    override fun getLayoutId(): Int = R.layout.activity_card_item

    override fun init(savedInstanceState: Bundle?) {

        val mCardAdapter = CardItemAdapter(this@CardItemActivity)
        mCardAdapter.itemDataSet = DataFactoryIp.createDataSet()

        val mCardTouchCallback = CardItemTouchCallback(mCardAdapter)
        val mItemTouchHelper = ItemTouchHelper(mCardTouchCallback)

        mBinding.rvCard.apply {
            layoutManager = CardLayoutManager()
            adapter = mCardAdapter
        }

        mItemTouchHelper.attachToRecyclerView(mBinding.rvCard)

        //mBinding.rvCard.layoutManager?.findViewByPosition(0)
        //mBinding.rvCard.layoutManager?.getChildAt(0)
    }

}